import Vue from 'vue'
import Router from 'vue-router'

import Home from '@/pages/home/home'
import Classify from '@/pages/classify/Classify'
import News from '@/pages/news/News'
import My from '@/pages/my/My'

// 商品展示
import Detail from '@/pages/detail/GoodDetail'
import Pay from '@/pages/pay/pay'
// 付款成功
import PaySuccess from '@/pages/pay/PaySuccess'

// news详情页面
import NewsDetail from '@/pages/news/NewsDetail'

// my里面的五个内容
import Collection from '@/pages/myContent/Collection'
import Address from '@/pages/myContent/Address'
// 添加地址
import Add from '@/pages/myContent/Add'
import Cart from '@/pages/myContent/Cart'
import Share from '@/pages/myContent/Share'
import AboutMe from '@/pages/myContent/AboutMe'

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      // name: 'home',
      // component: Home
      // 重复路由使用redirect解决
      redirect: {
        name: 'home'
      }
    },
    // 四个主页tab
    { path: '/home', name: 'home', component: Home, meta: {index: '1'} },
    { path: '/classify', name: 'Classify', component: Classify },
    { path: '/news', name: 'News', component: News },
    { path: '/my', name: 'My', component: My },
    // home里面的detail页面
    { path: '/detail', name: 'Detail', component: Detail },
    { path: '/pay', name: 'Pay', component: Pay },

    { path: '/paySuccess', name: 'PaySuccess', component: PaySuccess },

    { path: '/newsDetail', name: 'NewsDetail', component: NewsDetail },

    // my里面的五个内容
    { path: '/Collection', name: 'Collection', component: Collection },
    { path: '/Address', name: 'Address', component: Address },
    { path: '/Add', name: 'Add', component: Add },
    { path: '/Cart', name: 'Cart', component: Cart },
    { path: '/Share', name: 'Share', component: Share },
    { path: '/AboutMe', name: 'AboutMe', component: AboutMe }

  ],
  // 页面刷线自动回到顶部
  scrollBehavior (to, from, savedPosition) {
    return { x: 0, y: 0 }
  }
})
